The drag-and-drop part is missing; that still needs de-nautilus-ifying.
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
return TRUE;
}
+gboolean
+_gtk_bookmarks_manager_reorder_bookmark (GtkBookmarksManager *manager,
+ GFile *file,
+ gint new_position,
+ GError **error)
+{
+ GSList *link;
+ GFile *bookmarks_file;
+
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ if (!manager->bookmarks)
+ return FALSE;
+
+ link = find_bookmark_link_for_file (manager->bookmarks, file);
+ if (link)
+ {
+ GtkBookmark *bookmark = link->data;
+
+ manager->bookmarks = g_slist_remove_link (manager->bookmarks, link);
+ g_slist_free_1 (link);
+
+ manager->bookmarks = g_slist_insert (manager->bookmarks, bookmark, new_position);
+ }
+ else
+ {
+ gchar *uri = g_file_get_uri (file);
+
+ g_set_error (error,
+ GTK_FILE_CHOOSER_ERROR,
+ GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
+ "%s does not exist in the bookmarks list",
+ uri);
+
+ g_free (uri);
+
+ return FALSE;
+ }
+
+ bookmarks_file = get_bookmarks_file ();
+ save_bookmarks (bookmarks_file, manager->bookmarks);
+ g_object_unref (bookmarks_file);
+
+ notify_changed (manager);
+
+ return TRUE;
+}
+
gchar *
_gtk_bookmarks_manager_get_bookmark_label (GtkBookmarksManager *manager,
GFile *file)
GFile *file,
GError **error);
+gboolean _gtk_bookmarks_manager_reorder_bookmark (GtkBookmarksManager *manager,
+ GFile *file,
+ gint new_position,
+ GError **error);
+
gchar * _gtk_bookmarks_manager_get_bookmark_label (GtkBookmarksManager *manager,
GFile *file);
*
* * Fix FIXMEs
*
+ * * Grep for "NULL-GError" and see if they should be taken care of
+ *
* * Nautilus needs to use gtk_places_sidebar_set_uri() instead of built-in
* notification from the NautilusWindowSlot.
*/
reorder_bookmarks (GtkPlacesSidebar *sidebar,
int new_position)
{
-#if DO_NOT_COMPILE
GtkTreeIter iter;
- PlaceType type;
- int old_position;
+ char *uri;
+ GFile *file;
/* Get the selected path */
if (!get_selected_iter (sidebar, &iter)) {
}
gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter,
- PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type,
- PLACES_SIDEBAR_COLUMN_INDEX, &old_position,
+ PLACES_SIDEBAR_COLUMN_URI, &uri,
-1);
- if (type != PLACES_BOOKMARK ||
- old_position < 0 ||
- old_position >= nautilus_bookmark_list_length (sidebar->bookmarks)) {
- return;
- }
+ file = g_file_new_for_uri (uri);
+ _gtk_bookmarks_manager_reorder_bookmark (sidebar->bookmarks_manager, file, new_position, NULL); /* NULL-GError */
- nautilus_bookmark_list_move_item (sidebar->bookmarks, old_position,
- new_position);
-#endif
+ g_object_unref (file);
+ g_free (uri);
}
static void